home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #9
/
Amiga Plus CD - 2004 - No. 09.iso
/
amigaplus
/
tools
/
amigaos4_only
/
fracblank
/
source
/
fracsaver.c
< prev
next >
Wrap
C/C++ Source or Header
|
2004-08-03
|
4KB
|
111 lines
/*
** FracBlank - AmigaDOS 2.04 commodities utility screenblanker
**
** Copyright © 1991-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
**
** Cosmic flame fractal code derived from xlock source code
**
** Copyright © 1988-1991 by Patrick J. Naughton.
*/
#include <datatypes/pictureclass.h>
#include <proto/datatypes.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include "Frac.h"
#include "FracSaver.h"
// The process responsible for saving the screen data to the clipboard
struct Process *Saver;
/* SaverEntry():
*
* This background process handles the job of storing the
* contents of the screen in the clipboard.
*/
VOID SaverEntry() {
struct BitMap *BitMap;
// That's me
Saver = (struct Process *)IExec->FindTask(NULL);
IExec->ObtainSemaphoreShared(&BlankSemaphore);
IExec->Forbid();
// Create a bitmap to hold a copy of the screen
if (BitMap = IGraphics->AllocBitMap(Width,Height,DisplayDepth,0,RPort->BitMap)) {
STATIC ULONG Count = 1;
UBYTE LocalBuffer[256];
Object *Image;
// Copy the contents
IGraphics->BltBitMap(RPort->BitMap,0,0,BitMap,0,0,Width,Height,0xC0,(1L << DisplayDepth) - 1,NULL);
// Wait until they have arrived
IGraphics->WaitBlit();
IExec->Permit();
IExec->ReleaseSemaphore(&BlankSemaphore);
// Build a unique name, in case someone needs it
SPrintf(LocalBuffer,"FracBlank_%ld×%ld×%ld_%ld",Width,Height,DisplayDepth,Count++);
// Wrap the bitmap into an image object
if (Image = IDataTypes->NewDTObject(LocalBuffer,
DTA_SourceType, DTST_RAM,
DTA_GroupID, GID_PICTURE,
PDTA_NumColors, 1L << DisplayDepth,
PDTA_BitMap, BitMap,
PDTA_ModeID, IGraphics->GetVPModeID(&BlankScreen->ViewPort),
TAG_DONE)) {
struct ColorRegister *ColourMap;
struct BitMapHeader *BitMapHeader;
ULONG *ColourTab;
// Get the internal data storage pointers
if (IDataTypes->GetDTAttrs(Image,
PDTA_BitMapHeader, &BitMapHeader,
PDTA_ColorRegisters, &ColourMap,
PDTA_CRegs, &ColourTab,
TAG_DONE) == 3) {
LONG i;
// Fill in the header
BitMapHeader->bmh_Left = 0;
BitMapHeader->bmh_Top = 0;
BitMapHeader->bmh_Width = Width;
BitMapHeader->bmh_Height = Height;
BitMapHeader->bmh_Depth = DisplayDepth;
BitMapHeader->bmh_PageWidth = Width;
BitMapHeader->bmh_PageHeight = Height;
// Fill in the colour tables
for(i = 0; i < 1L << DisplayDepth; i++) {
ColourTab[i * 3 + 0] = Colours->Entry[i].Red;
ColourTab[i * 3 + 1] = Colours->Entry[i].Green;
ColourTab[i * 3 + 2] = Colours->Entry[i].Blue;
ColourMap[i].red = Colours->Entry[i].Red >> 24;
ColourMap[i].green = Colours->Entry[i].Green >> 24;
ColourMap[i].blue = Colours->Entry[i].Blue >> 24;
}
// Put the image into the clipboard
IIntuition->IDoMethod(Image,DTM_COPY,NULL);
}
IDataTypes->DisposeDTObject(Image);
}
else IGraphics->FreeBitMap(BitMap);
}
else {
IExec->Permit();
IExec->ReleaseSemaphore(&BlankSemaphore);
}
IExec->Forbid();
Saver = NULL;
}